<%@page pageEncoding="UTF-8" %>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
        <title>欢迎页面-X-admin2.0</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
	    <link rel="stylesheet" href="<%=request.getContextPath()%>/static/css/font.css">
		<link rel="stylesheet" href="<%=request.getContextPath()%>/static/css/xadmin.css">
        <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=kyGBgXXivSfAZIv07W0c5T4CX80DOp3r"></script>
        <style type="text/css">
        .baidu{
            height: 500px;
            padding-bottom: 15px;
            border-radius: 20px;
        }
        #showDate{
        	float:right;
        	/* margin-right:72%; */
        }
        #allmap {border-radius: 20px;width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
        </style>
    </head>
    <body onload="showtime()">
    <div class="x-body layui-anim layui-anim-up">
        <blockquote class="layui-elem-quote">
               欢迎管理员：<span class="x-red">张老师</span>！<div id="showDate"></div></blockquote>
        <fieldset class="layui-elem-field">
            <legend>实时体育活动</legend>
            <div class="layui-field-box">
                <div class="layui-col-md12  baidu">
                    <div id="allmap"></div>
                </div>
            </div>
        </fieldset>
        <fieldset class="layui-elem-field">
            <legend>开发团队</legend>
            <div class="layui-field-box">
                <table class="layui-table">
                    <tbody>
                        <tr>
                            <th>版权所有</th>
                            <td>正鼎软件科技有限公司
                                <a href="http://www.xxx.com/" class='x-a' target="_blank">访问官网</a></td>
                        </tr>
                        <tr>
                            <th>开发者</th>
                            <td>正鼎软件(113664000@qq.com)</td></tr>
                    </tbody>
                </table>
            </div>
        </fieldset>
    </div>
<script type="text/javascript" src="<%=request.getContextPath()%>/static/js/jquery.js"></script>
<script type="text/javascript">
	var siv;
    var baidu;
	var m;
	var but = document.getElementById("showDate");
	var data = new Date();
	var Week = data.getDay();//星期几
	var year = data.getFullYear();//年
	var month = data.getMonth()+1;//月
	var day = data.getDate();//日
	var hour = data.getHours();//时
	var secs = data.getSeconds();//秒
	function showtime(){
		siv = setInterval(function(){
			data = new Date();
			year = data.getFullYear();//年
			month = data.getMonth()+1;//月
			day = data.getDate();//日
			Week = data.getDay();//星期几
			hour = data.getHours();//时
			mins = data.getMinutes();//分
			secs = data.getSeconds();//秒
			but.innerText="当前时间:"+year+"-"+month+"-"+day+"		"+hour+":"+mins+":"+secs;
		},1000)
		if((month>=2&&month<=9)||(month>=9&&month<12)){
			if(hour>=8&&hour<=22){
				var dataDuan;
				data = new Date();
				Week = data.getDay();//星期几
				year = data.getFullYear();//年
				month = data.getMonth()+1;//月
				day = data.getDate();//日
				hour = data.getHours();//时
				mins = data.getMinutes();//分	
				if(time_range ("08:20", "10:00")){
					dataDuan=2;
				}
				else if(time_range ("10:20", "12:00")){
					dataDuan=3;
				}
				else if(time_range ("14:00", "15:40")){
					dataDuan=4;
				}
				else if(time_range ("16:00", "17:40")){
					dataDuan=5;
				}
				else{
					dataDuan=-1;
				}
/* 				if((hour>=9&&hour<10)||(hour>=8&&hour<9&&mins>20)){
					dataDuan=2;
				}
				else if((hour>=11&&hour<=12)||(hour>=10&&hour<11&&mins>20)){
					dataDuan=3;
				}
				else if((hour>=14&&hour<=15)||(hour>=15&&hour<14&&mins<=40)){
					dataDuan=4;
				}
				else if((hour>=16&&hour<=17)||(hour>=17&&hour<18&&mins<=40)){
					dataDuan=5;
				}	 */
				$.ajax({ 
			        type: "get", 
			        data :{"week":Week,"dataDuan":dataDuan},
			        dataType: "json", 
			        url:"<%=request.getContextPath()%>/coursePlace/baidu",
			        success: function(data) {
			        	addMarker(data.items);
			        },
			        error:function(data){
	    	            layer.alert('数据查询出错',{
	    	                icon:5});
			        }
			    });
		        
 				baidu = setInterval(function(){
					data = new Date();
					Week = data.getDay();//星期几
					year = data.getFullYear();//年
					month = data.getMonth()+1;//月
					day = data.getDate();//日
					hour = data.getHours();//时
					mins = data.getMinutes();//分
					$.ajax({ 
				        type: "get", 
				        data :{"week":Week,"dataDuan":dataDuan},
				        dataType: "json", 
				        url:"<%=request.getContextPath()%>/coursePlace/baidu",
				        success: function(data) {
				        	addMarker(data.items);
				        },
				        error:function(data){
		    	            layer.alert('数据查询出错',{
		    	                icon:5});
				        }
				    });
				},600000) 
				
			}else{
	            layer.alert("您好"+hour+"时非上课时间",{
	                icon:5});
			}
		}else{
            layer.alert("您好"+month+"月放假时间",{
                icon:5});
		}
		
	}
	
var time_range = function (beginTime, endTime) {
     var strb = beginTime.split (":");
     if (strb.length != 2) {
         return false;
     }
 
     var stre = endTime.split (":");
     if (stre.length != 2) {
         return false;
     }
 
     var b = new Date ();
     var e = new Date ();
     var n = new Date (); 
     b.setHours (strb[0]);
     b.setMinutes (strb[1]);
     e.setHours (stre[0]);
     e.setMinutes (stre[1]);
 
     if (n.getTime () - b.getTime () > 0 && n.getTime () - e.getTime () < 0) {
         return true;
     } else {
         return false;
     }
 }
 
 
 
/* var points = [  
	  {"lng":117.252201,"lat":31.761375,"id":1,"name":"排球俱乐部","address":"6#楼西侧排球场"},  
	  {"lng":117.252443,"lat":31.762043,"id":2,"name":"篮球俱乐部","address":"6#楼西侧篮球场"},  
	  {"lng":117.252443,"lat":31.7607,"id":3,"name":"网球俱乐部","address":"6#楼西侧网球场"},
	  {"lng":117.254384,"lat":31.761866,"id":4,"name":"击剑俱乐部","address":"7#主楼10楼击剑馆"},  
	  {"lng":117.254851,"lat":31.76202,"id":5,"name":"双节棍俱乐部","address":"7#主楼1楼A馆"},  
	  {"lng":117.254743,"lat":31.762028,"id":6,"name":"xxx俱乐部","address":"7#主楼1楼B馆"},
	  {"lng":117.254572,"lat":31.762035,"id":7,"name":"xxx俱乐部","address":"7#主楼1楼C馆"},  
	  {"lng":117.254438,"lat":31.762043,"id":8,"name":"xxx俱乐部","address":"7#主楼1楼D馆"},  
	  {"lng":117.254276,"lat":31.762051,"id":9,"name":"xxx俱乐部","address":"7#主楼1楼F馆"},  
	  {"lng":117.254492,"lat":31.761694,"id":10,"name":"xxx俱乐部","address":"主楼7#广场"},  
	  {"lng":117.268325,"lat":31.754905,"id":11,"name":"排球俱乐部","address":"50#北侧排球场"},
	  {"lng":117.268105,"lat":31.754609,"id":12,"name":"篮球俱乐部","address":"50#楼北侧篮球场"},  
	  {"lng":117.259244,"lat":31.757983,"id":13,"name":"F&amp;D舞蹈俱乐部","address":"体育馆三楼"},  
	  {"lng":117.259634,"lat":31.758151,"id":14,"name":"轮滑俱乐部","address":"体育馆主馆"},
	  {"lng":117.260097,"lat":31.757998,"id":15,"name":"xxx俱乐部","address":"体育馆副馆"},  
	  {"lng":117.260119,"lat":31.758251,"id":16,"name":"壁球乐部","address":"体育馆壁球场"},  
	  {"lng":117.257353,"lat":31.758877,"id":17,"name":"xxx俱乐部","address":"塑胶田径场"},  
	  {"lng":117.257955,"lat":31.758992,"id":18,"name":"xxx俱乐部","address":"塑胶田径场 附属楼22#一楼南侧"},  
	  {"lng":117.257748,"lat":31.758432,"id":19,"name":"xxx俱乐部","address":"塑胶足球场"},
	  {"lng":117.258179,"lat":31.758447,"id":20,"name":"xxx俱乐部","address":"田径场"},  
	  {"lng":117.258179,"lat":31.758447,"id":21,"name":"xxx俱乐部","address":"田径场附属楼22#北侧一楼道馆"},  
	  {"lng":117.257865,"lat":31.757687,"id":22,"name":"xxx俱乐部","address":"田径场附属楼22#南侧健身房"},
	  ];  */


	  function addMarker(points) {
	      //循环建立标注点
	      for(var i=0, pointsLen = points.length; i<pointsLen; i++) {
	          var point = new BMap.Point(points[i].lng, points[i].lat); //将标注点转化成地图上的点
	          var marker = new BMap.Marker(point); //将点转化成标注点
	          map.addOverlay(marker);  //将标注点添加到地图上
	          //添加监听事件
	          (function() {
	              var thePoint = points[i];
	              marker.addEventListener("click",
	              //显示信息的方法
	                  function() {
	                  showInfo(this,thePoint);
	              });
	           })();  
	      }
	  }
	  function showInfo(thisMarker,point) {
	      //获取点的信息
	      var sContent = 
	      '<ul style="margin:0 0 5px 0;padding:0.2em 0">'  
	      +'<li style="line-height: 26px;font-size: 15px;">'  
	      +'<span style="width: 70px;">课程名称：</span>' + point.courseName + '</li>'  
	      +'<li style="line-height: 26px;font-size: 15px;">'  
	      +'<span style="width: 80px;">授课老师：</span>' + point.teacher + '</li>'  
	      +'<li style="line-height: 26px;font-size: 15px;">' 
	      +'<span style="width: 90px;">授课地点：</span>' + point.coursePlace + '</li>'  
	      +'<li style="line-height: 26px;font-size: 15px;"><span style="width: 80px;">签到人数：</span>'+point.peopleNum+'</li>'  
	      +'</ul>';
	      var infoWindow = new BMap.InfoWindow(sContent); //创建信息窗口对象
	      thisMarker.openInfoWindow(infoWindow); //图片加载完后重绘infoWindow
	  }
	  // 百度地图API功能
	  var map = new BMap.Map("allmap");          
	  map.centerAndZoom(new BMap.Point(117.262769,31.75969), 16);
	  var local = new BMap.LocalSearch(map, {
	    renderOptions:{map: map}
	  });   
	/*    var result='00';
	  //map.setCurrentCity("合肥");          // 设置地图显示的城市 此项是必须设置的
	  if(result){
	 
	  }*/
	  map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放

	  //addMarker(points); //添加标注
</script>
    </body>
</html>